package com.ruoyi.web.controller.dispatch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DispatchDataReportRecords;
import com.ruoyi.system.service.IDispatchDataReportRecordsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 数据填报记录Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/dispatchDataReportRecords")
public class DispatchDataReportRecordsController extends BaseController
{
    @Autowired
    private IDispatchDataReportRecordsService dispatchDataReportRecordsService;

    /**
     * 查询数据填报记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchDataReportRecords:list')")
    @GetMapping("/list")
    public TableDataInfo list(DispatchDataReportRecords dispatchDataReportRecords)
    {
        startPage();
        List<DispatchDataReportRecords> list = dispatchDataReportRecordsService.selectDispatchDataReportRecordsList(dispatchDataReportRecords);
        return getDataTable(list);
    }

    /**
     * 导出数据填报记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchDataReportRecords:export')")
    @Log(title = "数据填报记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DispatchDataReportRecords dispatchDataReportRecords)
    {
        List<DispatchDataReportRecords> list = dispatchDataReportRecordsService.selectDispatchDataReportRecordsList(dispatchDataReportRecords);
        ExcelUtil<DispatchDataReportRecords> util = new ExcelUtil<DispatchDataReportRecords>(DispatchDataReportRecords.class);
        util.exportExcel(response, list, "数据填报记录数据");
    }

    /**
     * 获取数据填报记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchDataReportRecords:query')")
    @GetMapping(value = "/{dataReportRecordsId}")
    public AjaxResult getInfo(@PathVariable("dataReportRecordsId") Long dataReportRecordsId)
    {
        return success(dispatchDataReportRecordsService.selectDispatchDataReportRecordsByDataReportRecordsId(dataReportRecordsId));
    }

    /**
     * 新增数据填报记录
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchDataReportRecords:add')")
    @Log(title = "数据填报记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DispatchDataReportRecords dispatchDataReportRecords)
    {
        return toAjax(dispatchDataReportRecordsService.insertDispatchDataReportRecords(dispatchDataReportRecords));
    }

    /**
     * 修改数据填报记录
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchDataReportRecords:edit')")
    @Log(title = "数据填报记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DispatchDataReportRecords dispatchDataReportRecords)
    {
        return toAjax(dispatchDataReportRecordsService.updateDispatchDataReportRecords(dispatchDataReportRecords));
    }

    /**
     * 删除数据填报记录
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchDataReportRecords:remove')")
    @Log(title = "数据填报记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dataReportRecordsIds}")
    public AjaxResult remove(@PathVariable Long[] dataReportRecordsIds)
    {
        return toAjax(dispatchDataReportRecordsService.deleteDispatchDataReportRecordsByDataReportRecordsIds(dataReportRecordsIds));
    }
}
